<?php
/*********** 一主多从配置 *
return [
    'class'         => 'yii\db\Connection',
    'dsn'           => 'mysql:host=127.0.0.1;dbname=test',
    'username'      => 'root',
    'password'      => '123456',
    'charset'       => 'utf8mb4',
    //'tablePrefix'   => 'tb_',
    'slaveConfig'   => [
        'username'      => 'root',
        'password'      => '123456',
        'attributes'    => [
            PDO::ATTR_TIMEOUT   => 10,
        ],
    ],
    'slaves'        => [
        ['dsn'  => 'mysql:host=127.0.0.1;dbname=test'],
        ['dsn'  => 'mysql:host=127.0.0.2;dbname=test'],
    ]
];
*/

/*********** 多主多从配置 **/
return [
    'class'         => 'yii\db\Connection',
    'charset'       => 'utf8mb4',
    //'tablePrefix'   => 'tb_',
    'masterConfig'  => [
        'username'      => 'root',
        'password'      => '123456',
        'attributes'    => [
            PDO::ATTR_TIMEOUT   => 10,
        ],
    ],
    'masters'       => [
        ['dsn'  => 'mysql:host=127.0.0.1;dbname=test'],
        ['dsn'  => 'mysql:host=127.0.0.2;dbname=test'],
    ],
    'slaveConfig'   => [
        'username'      => 'root',
        'password'      => '123456',
        'attributes'    => [
            PDO::ATTR_TIMEOUT   => 10,
        ],
    ],
    'slaves'        => [
        ['dsn'  => 'mysql:host=127.0.0.1;dbname=test'],
        ['dsn'  => 'mysql:host=127.0.0.2;dbname=test'],
        ['dsn'  => 'mysql:host=127.0.0.3;dbname=test'],
        ['dsn'  => 'mysql:host=127.0.0.4;dbname=test'],
    ]
];
